package com.cyandpos.pad.cateringformat.orderinfo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cyandpos.pad.R;
import com.cyandpos.pad.pay.adapter.BaseViewHolder;
import com.cyandpos.pad.posdata.Goods;
import com.cyandpos.pad.posdata.Order;
import com.cyandpos.pad.utils.MoneyUtils;

import java.util.ArrayList;
import java.util.List;

public class OrderInfoItemAdapter extends BaseAdapter {
    private Context context;
    private List<Goods> skfs = new ArrayList<>();
    private int clickTemp = -1;//标识被选择的item
    private int[] clicked;
    private boolean mFlag;
    private boolean isMore=true;
    public OrderInfoItemAdapter(Context mContext, List<Goods> mSkfs) {
        super();
        this.context = mContext;
        this.skfs = mSkfs;
    }

    @Override
    public int getCount() {
        return skfs.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null){
            convertView = LayoutInflater.from(context).inflate
                    (R.layout.item_orderinfo_order_goods, parent, false);
        }

        LinearLayout lin_table_item = BaseViewHolder.get(convertView, R.id.lin_orderfood_goodsitem);
        TextView tv_goodsinfo = BaseViewHolder.get(convertView, R.id.tv_orderfood_goodsinfo);
        TextView tv_goodsnum = BaseViewHolder.get(convertView, R.id.tv_orderfood_info_goodsnum);
        TextView tv_paymoney = BaseViewHolder.get(convertView, R.id.tv_orderfood_info_paymoney);
       // tv_info_inx.setText((position+1)+"");
        tv_goodsinfo.setText(skfs.get(position).getName());
        tv_goodsnum.setText(skfs.get(position).getSaleCount());
        tv_paymoney.setText( MoneyUtils.getMoneyStr(MoneyUtils.getMoneyInt(skfs.get(position).getSaleMoney())));


        return convertView;
    }
    public void setSelectPos(int position,boolean flag) {
        clickTemp = position;
        mFlag = flag;
        notifyDataSetChanged();
    }

}
